#include "test_image_pixels.h"

ONCE_FCT_START(cacher,rect)
{
	g_object_set(G_OBJECT(rect),
	 "visibility",GOO_CANVAS_ITEM_INVISIBLE,
	  NULL);
	  ONCE(montrer,rect);
ONCE_FCT_END;

ONCE_FCT_START(montrer,rect)
{
	g_object_set(G_OBJECT(rect),"visibility",GOO_CANVAS_ITEM_VISIBLE,NULL);
	ONCE(cacher,rect);
ONCE_FCT_END;

static gboolean say_it_cross(GooCanvasItem*item,GooCanvasItem*target,GdkEventCrossing*event, gpointer txt)
{
	g_print("%s\n",(char*)txt);
}

static gboolean say_it_press(GooCanvasItem*item,GooCanvasItem*target,GdkEventButton*event, gpointer txt)
{
	g_print("%s\n",(char*)txt);
}

int main(int argc,char** argv)
{
	GtkWidget* win,*canvas;
	GooCanvasItem* root,*img;
	GdkPixbuf* fp=NULL;
	GError* erreur=NULL;
	char* txt1="button-press-event";
	char* txt2="enter-notify-event";
	char* txt3="leave-notify-event";

	CANVAS_WIN_ROOT_NEW(canvas,win,root,320,240);
	fp = gdk_pixbuf_new_from_file("dessin_transparent_contour.png",&erreur);
	img = goo_canvas_image_new(root,fp,10,10,NULL);
	if(!img)
	{
		g_print("pb for img\n");
		exit(0);
	}
	g_print("length:%d\n",strlen(txt1));
	g_signal_connect(img,"button-press-event",(GtkSignalFunc)say_it_press,txt1);
	g_signal_connect(img,"enter-notify-event",(GtkSignalFunc)say_it_cross,txt2);
	g_signal_connect(img,"leave-notify-event",(GtkSignalFunc)say_it_cross,txt3);

	g_object_set(root,"fill-color","red",NULL);
	g_print("np");

	//ONCE(cacher,rect);

	gtk_main();

	return 0;

}